var aesKey = "abcdefgabcdefg12"; // 随机产生
var publicKey = "-----BEGIN PUBLIC KEY-----\n" +
    "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApnoKdG/puXlnezRMa+yE\n" +
    "VRwhzn5uUAJaxx7ucFWkV7FZZdxzi+fW/KAj/OFf37FPLkMj42fo3YlX6gJaCLqh\n" +
    "qIZC4LymL3pPQ2cPWgv20AZAVJc748w4A0gsnw3XYglml/WgDcH8vaGN0qNBnKdR\n" +
    "5Ck5MgCMbKDO+tQKqffn7ekKn8dezHhW5Fbm2vX5JDs2xxtdOPm/5H+aQqYMaErh\n" +
    "Cnmosxqeh+1K0ltLMzAqhoFf+0Ll4fl2Hs/bQcWcjATyjz9vWJUuAp6qypKqElBl\n" +
    "Y86jTgqFk283TNSMw/4Mzfq1rBG0LNKvIvI9E38SbKJ2ovejUo3ChF1aNue6bpYr\n" +
    "9QIDAQAB\n" +
    "-----END PUBLIC KEY-----"; // 公钥会从服务端获取
/**
 * 加密（需要先加载aes.min.js文件）
 * @param {string} word
 * @param {string} key
 * @returns {*}
 */
function aesEncrypt(word,key){
    var key = CryptoJS.enc.Utf8.parse(key);
    var srcs = CryptoJS.enc.Utf8.parse(word);
    var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
    return encrypted.toString();
}

/**
 * 解密
 * @param {string} word
 * @param {string} key
 * @returns {*}
 */
function decrypt(word, key){
    var key = CryptoJS.enc.Utf8.parse(key);
    var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}

